<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>杨辉三角</title>
</head>
<body>
  <script>
    function fn(numRows) {
      const ret = []
      for (let i = 0; i < numRows; i++) {
        const row = new Array(i + 1).fill(1)
        for (let j = 1; j < row.length - 1; j++) {
          row[j] = ret[i - 1][j - 1] + ret[i - 1][j]
        }
        ret.push(row)
      }
      return ret
    }
    console.log(fn(5))
  </script>
</body>
</html>